"use client"
import { useRouter } from 'next/navigation';
import React, { useState,useEffect } from 'react';
import type { RadioChangeEvent, DatePickerProps } from 'antd';
import { FormProps, Rate, Button, Radio, Form, Input, DatePicker, InputNumber } from 'antd';
import { useForm } from 'antd/es/form/Form';

type FieldType = {
  username?: string;
  password?: string;
  remember?: string;
};
const style: React.CSSProperties = {
  display: 'flex',
  flexDirection: 'column',
  gap: 8,
};


const addData = (props) => {
  let router = useRouter()

  const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
    console.log('Success:', values);
    router.push("/liyi")
  };

  const [value, setValue] = useState(1);

  const onChange = (e: RadioChangeEvent) => {
    setValue(e.target.value);
  };
  console.log(props.params);
  
  let [form] = useForm()
  useEffect(()=>{
    form.getFieldsError()
  },[])

  return (
    <Form
      form={form}
      onFinish={onFinish}
      autoComplete="off"
    >
      <Form.Item<FieldType>
        label="客户名称"
        name="name"
        rules={[{ required: true, message: '请输入客户名称!' }]}
      >
        <Input />
      </Form.Item>

      <Form.Item<FieldType>
        label="客户状态"
        name="flag"
      >
        <Radio.Group
          style={style}
          onChange={onChange}
          value={value}
          options={[
            { value: 0, label: '跟进' },
            { value: 1, label: '已经跟进' },
          ]}
        />
      </Form.Item>

      <Form.Item<FieldType>
        label="客户星级"
        name="address"
      >
        <Rate />
      </Form.Item>

      <Form.Item<FieldType>
        label="首联系人"
        name="topOne"
        rules={[{ required: true, message: '请输入首联系人!' }]}
      >
        <Input />
      </Form.Item>
      <Form.Item<FieldType>
        label="手机号码"
        name="call"
        rules={[{ required: true, message: '请输入手机号码!' }]}
      >
        <Input />
      </Form.Item>

      <Form.Item<FieldType>
        label="手机号码"
        name="time"
        rules={[{ required: true, message: '请输入手机号码!' }]}
      >
        <DatePicker onChange={onChange} />
      </Form.Item>


      <Form.Item<FieldType>
        label="未跟进天数"
        name="day"
        rules={[{ required: true, message: '请输入手机号码!' }]}
      >
        <Form.Item>
          <InputNumber />
        </Form.Item>
      </Form.Item>



      <Form.Item label={null}>
        <Button type="primary" htmlType="submit">
          确定
        </Button>
      </Form.Item>
    </Form>
  )
};

export default addData;